﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Happy.Examples.OrderManagement.Domain.Orders.States
{
    internal static class OrderStateFactory
    {
        private static Dictionary<OrderStatus, Func<OrderState>> _StatusToStateMaps = new Dictionary<OrderStatus, Func<OrderState>>
        {
            { OrderStatus.New, ()=>new NewState() },
            { OrderStatus.Saved, ()=>new SavedState() },
            { OrderStatus.Auditing, ()=>new AuditingState() },
            { OrderStatus.Audited, ()=>new AuditedState() }
        };

        public static OrderState Create(Order order, OrderStatus status)
        {
            var state = _StatusToStateMaps[status]();

            state.Order = order;

            return state;
        }
    }
}
